home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 2003 August / MW 8 2003 CD1.iso / Inside Macworld / Product News / gimp-1.2.4.sit / gimp-1.2.4 / plug-ins / perl / examples / goldenmean < prev    next >
Encoding:
Text File  |  2000-05-21  |  1.1 KB  |  48 lines

  1. #!/usr/app/bin/perl
  2.  
  3. eval 'exec /usr/app/bin/perl  -S $0 ${1+"$@"}'
  4.     if 0; # not running under some shell
  5.  
  6. use Gimp qw(:auto __ N_);
  7. use Gimp::Fu;
  8.  
  9. sub goldenmean {
  10.     my ($short, $type) = @_;
  11.  
  12.     $long = int(($short * 1.618) + 0.5);
  13.  
  14.     $width = $short;
  15.     $height = $long;
  16.  
  17.     if ($type == 1) {
  18.         $width = $long;
  19.         $height = $short;
  20.     }
  21.  
  22.     $img = gimp_image_new($width, $height, RGB);
  23.     $layer = gimp_layer_new($img, $width, $height, RGB_IMAGE, "Layer 1", 100, NORMAL_MODE);
  24.  
  25.     gimp_image_add_layer($layer, -1);
  26.     gimp_palette_set_background([255, 255, 255]);
  27.     $layer->gimp_edit_fill(BG_IMAGE_FILL);
  28.  
  29.     return $img;
  30. }
  31.  
  32. register    "golden_mean",
  33.         "Creates a new image with a ratio according to the Golden Mean",
  34.         "Select shortest side and orientation and I will automagically calculate the long side. As a plug-in companion, see <Image>/Center Guide.",
  35.         "Claes G Lindblad <claesg\@algonet.se>",
  36.         "Claes G Lindblad <claesg\@algonet.se>",
  37.         "990328",
  38.         N_"<Toolbox>/Xtns/Render/Golden Mean...",
  39.         undef,
  40.     [
  41.     [PF_INT32, "short", "Shortest side", 233],
  42.     [PF_RADIO, "type", "Orientation", 0, [Portrait => 0, Landscape => 1]]
  43.     ],
  44.     \&goldenmean;
  45.  
  46. exit main;
  47.  
  48.